<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>侦听器b</title>
    <script src="vue3.js"></script>
</head>
<body>
    <div id="app">
        <h1>{{count}}</h1>
        <button @click="jia1">+1</button>
        <button @click="jian1">-1</button>
        <button @click="jia2">+2</button>
        <button @click="jian2">-2</button>
    </div>
    <script>
        const {createApp} = Vue
        createApp({
            data(){
                return{
                    count:0
                }
            },
            methods:{
                jia1(){
                    this.count += 1
                },
                jia2(){
                    this.count += 2
                },
                jian1(){
                    this.count -= 1
                },
                jian2(){
                    this.count -= 2
                }
            },
            watch:{
                count(newCount,oldCount){
                    console.log(newCount,oldCount)
                }
            }
        }).mount('#app')
    </script>
</body>
</html>